Skip to content

Conversation

@anonymous-dyce
Copy link
Contributor

I created a controller, CalendarBreakController.java, that contains API endpoints to receive requests from frontend (calendar.md) regarding the creating, displaying, editing, and deleting of breaks. I also created three files, CalendarBreak.java, CalendarBreakRepository.java, and CalendarBreakService.java, which create the database for saving breaks from frontend.

API Endpoints Created/Enhanced:

1. POST /api/calendar/breaks/create (FIXED & ENHANCED)

  • Validates that name is not empty
  • Implements next-non-break-day logic
  • Returns complete break object with all fields

2. PUT /api/calendar/breaks/{id} (NEW)

  • Edit break name and description
  • Proper error handling for non-existent breaks
  • Returns updated break object

3. DELETE /api/calendar/breaks/{id} (ENHANCED)

  • Cleaner path structure
  • Proper success/error messages
  • Events stay on their current dates (no automatic reversal)

4. GET /api/calendar/breaks/ (VERIFIED)

  • Returns all breaks with name and description fields
  • Properly populated responses

5. GET /api/calendar/breaks/by-date (VERIFIED)

  • Retrieves breaks for a specific date
  • Works with the new fields

6. GET /api/calendar/breaks/is-break-day (VERIFIED)

  • Checks if a date is a break day
  • Returns boolean response

7. GET /api/calendar/breaks/{id} (VERIFIED)

  • Retrieves specific break by ID

Key Technical Changes:

CalendarBreak.java - Updated entity with [name] fields

CalendarBreakService.java - Enhanced with: findNextNonBreakDay() method for calculating next available date
, and [updateBreak()] method for editing breaks

CalendarBreakController.java - Completely redesigned with new base path [/api/calendar/breaks] to avoid conflicts
, proper input validation
, comprehensive error handling
, all 7 endpoints with clean architecture

Database Schema - Updated calendar_breaks table with [name] columns

Testing Results:
All endpoints have been tested and verified working:

✓ Create breaks with custom names and descriptions
✓ Edit breaks
✓ Delete breaks
✓ Retrieve all breaks
✓ Retrieve breaks by date
✓ Check if date is a break day
✓ Proper error handling with appropriate HTTP status codes

@jm1021
Copy link
Contributor

jm1021 commented Jan 28, 2026

I am still not sure why we have a Calendar Break entity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants